﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>engage_resume</title>
    <script src="~/lib/axios/dist/axios.js"></script>
    <script src="~/lib/vue/dist/vue.js"></script>
    <script src="~/lib/element-ui/lib/index.js"></script>
    <link href="~/lib/element-ui/lib/theme-chalk/index.css" rel="stylesheet" />
</head>
<body>
    <div id="app">
        <el-container>
            <el-card class="box-card">
                <el-main>
                    <el-form ref="form" :model="form" :rules="rules" label-width="80px" :inline="true" size="mini">
                        <el-form-item label="职位名称" prop="vaul">
                            <div class="block">
                                <el-cascader v-model="form.vaul"
                                             :options="list"
                                             ref="cascaderAddr1"
                                             style="width:160px "
                                             :disabled="bol"
                                             @@change="adminSelect1"></el-cascader>
                            </div>
                        </el-form-item>
                        <el-form-item label="招聘类型" prop="engage_type">
                            <el-select v-model="form.engage_type" placeholder="请选择招聘类型" style="width: 160px " :disabled="bol">
                                <el-option label="校园招聘" value="校园招聘"></el-option>
                                <el-option label="社会招聘" value="社会招聘"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="姓名" prop="human_name">
                            <el-input v-model="form.human_name" style="width: 160px "></el-input>
                        </el-form-item>
                        <el-form-item label="性别" prop="human_sex">
                            <el-select v-model="form.human_sex" style="width: 160px " :disabled="true">
                                <el-option label="男" value="男"></el-option>
                                <el-option label="女" value="女"></el-option>
                            </el-select>
                        </el-form-item>
                        <div class="kbl">
                            <el-form-item prop="file">
                                <el-upload class="upload-demo"
                                           action="''"
                                           :on-remove="handleRemove"
                                           :on-change="handleAvatarChangeIcon"
                                           :file-list="fileList"
                                           list-type="picture-card"
                                           :limit="1"
                                           :auto-upload="false">
                                    <i slot="default" class="el-icon-plus"></i>
                                </el-upload>
                            </el-form-item>
                        </div>
                        <el-form-item label="EMAIL" prop="human_email">
                            <el-input v-model="form.human_email" style="width: 160px "></el-input>
                        </el-form-item>
                        <el-form-item label="电话" prop="human_telephone">
                            <el-input v-model="form.human_telephone" style="width: 160px "></el-input>
                        </el-form-item>
                        <el-form-item label="家庭电话" prop="human_homephone">
                            <el-input v-model="form.human_homephone" style="width: 160px "></el-input>
                        </el-form-item>
                        <el-form-item label="手机" prop="human_mobilephone">
                            <el-input v-model="form.human_mobilephone" style="width: 160px "></el-input>
                        </el-form-item>
                        <el-form-item label="住址" prop="human_address">
                            <el-select v-model="form.human_address" placeholder="请选择地址" style="width: 160px ">
                                <el-option label="湖南湘潭" value="湖南湘潭"></el-option>
                                <el-option label="湖南长沙" value="湖南长沙"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="邮编" prop="human_postcode">
                            <el-input v-model="form.human_postcode" style="width: 160px"></el-input>
                        </el-form-item>
                        <el-form-item label="国籍" prop="human_nationality">
                            <template>
                                <el-select v-model="form.human_nationality" placeholder="请选择国籍" style="width: 160px ">
                                    <el-option v-for="item in list1"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="出生地" prop="human_birthplace">
                            <el-select v-model="form.human_birthplace" placeholder="请选择出生地" style="width: 160px ">
                                <el-option label="湖南湘潭" value="湖南湘潭"></el-option>
                                <el-option label="湖南长沙" value="湖南长沙"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="生日" prop="human_birthday">
                            <el-date-picker style="width: 160px " type="date" v-model="form.human_birthday" :disabled="true"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="民族" prop="human_race">
                            <template>
                                <el-select v-model="form.human_race" placeholder="请选择民族" style="width: 160px ">
                                    <el-option v-for="item in list2"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="宗教信仰" prop="human_religion">
                            <template>
                                <el-select v-model="form.human_religion" placeholder="请选择宗教信仰" style="width: 160px ">
                                    <el-option v-for="item in list3"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="政治面貌" prop="human_party">
                            <template>
                                <el-select v-model="form.human_party" placeholder="请选择政治面貌" style="width: 160px ">
                                    <el-option v-for="item in list4"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="身份证号" prop="human_idcard">
                            <el-input v-model="form.human_idcard" style="width: 160px" @@blur="getName(form.human_idcard)"></el-input>
                        </el-form-item>
                        <el-form-item label="年龄" prop="human_age">
                            <el-input v-model="form.human_age" style="width: 160px " :disabled="true"></el-input>
                        </el-form-item>
                        <el-form-item label="毕业院校" prop="human_college">
                            <el-select v-model="form.human_college" placeholder="请选择毕业院校" style="width: 160px ">
                                <el-option label="湖南农业大学" value="湖南农业大学"></el-option>
                                <el-option label="湖南理工大学" value="湖南理工大学"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="学历" prop="human_educated_degree">
                            <template>
                                <el-select v-model="form.human_educated_degree" placeholder="请选择学历" style="width: 160px ">
                                    <el-option v-for="item in list6"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="教育年限" prop="human_educated_years">
                            <template>
                                <el-select v-model="form.human_educated_years" placeholder="请选择教育年限" style="width: 160px ">
                                    <el-option v-for="item in list5"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="学历专业" prop="human_educated_major">
                            <template>
                                <el-select v-model="form.human_educated_major" placeholder="请选择学历专业" style="width: 160px ">
                                    <el-option v-for="item in list7"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="薪酬要求" prop="demand_salary_standard">
                            <el-input v-model.number="form.demand_salary_standard" style="width: 160px "></el-input>
                        </el-form-item>
                        <el-form-item label="特长" prop="human_specility">
                            <template>
                                <el-select v-model="form.human_specility" placeholder="请选择特长" style="width: 160px ">
                                    <el-option v-for="item in list8"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="爱好" prop="human_hobby">
                            <template>
                                <el-select v-model="form.human_hobby" placeholder="请选择爱好" style="width: 160px ">
                                    <el-option v-for="item in list9"
                                               :key="item.pbc_id"
                                               :label="item.attribute_name"
                                               :value="item.attribute_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item label="登记人" prop="register">
                            <template>
                                <el-select v-model="form.register" placeholder="请选择登记人" style="width: 160px ">
                                    <el-option v-for="item in listm"
                                               :key="item.u_id"
                                               :label="item.u_true_name"
                                               :value="item.u_true_name">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                        <el-form-item prop="regist_time" label="注册时间">
                            <el-date-picker style="width: 175px " :disabled="true" type="datetime" placeholder="选择日期" v-model="form.regist_time"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="个人履历" prop="human_history_records">
                            <el-input type="textarea" v-model="form.human_history_records" style="width: 1090px "></el-input>
                        </el-form-item>
                        <el-form-item label="备注" prop="remark">
                            <el-input type="textarea" v-model="form.remark" style="width: 1090px "></el-input>
                        </el-form-item>
                        <el-form-item class="_klpo">
                            <template>
                                <el-button type="primary" @@click="submitForm('form')">提交</el-button>
                            </template>
                            <el-button @@click="resetForm('form')" :disabled="bol">清空</el-button>
                            <el-button @@click="eas()" :style=divzx2>返回</el-button>
                        </el-form-item>
                    </el-form>
                </el-main>
            </el-card>
        </el-container>
    </div>
    <script type="text/javascript">
        var vm = new Vue({
            el: "#app",
            data: {
                divzx2:"display: none;",
                bol: false,
                list: [],  //职位
                list1: [],//国籍
                list2: [],//民族
                list3: [],//宗教信仰
                list4: [],//政治面貌
                list5: [],//教育年限
                list6: [],//学历
                list7: [],//专业
                list8: [],//特长
                list9: [],//爱好
                listm:[],//用户
                fileList: [],//图片
                form: {
                    file:null,
                    vaul:[],
                    human_major_kind_id: '',
                    human_major_kind_name: '',
                    human_major_id: '',
                    human_major_name: [],
                    engage_type: '',
                    human_name: '',
                    human_sex: '',
                    human_email: '',
                    human_telephone: '',
                    human_address: '',
                    human_postcode: '',
                    human_nationality: '',
                    human_birthplace: '',
                    human_birthday: '',
                    human_race: '',
                    human_religion: '',
                    human_party: '',
                    human_idcard: '',
                    human_age: '',
                    human_college: '',
                    human_educated_degree: '',
                    human_educated_years: '',
                    human_educated_major: '',
                    demand_salary_standard: '',
                    regist_time: '',
                    human_specility: '',
                    human_hobby: '',
                    human_history_records: '',
                    remark: '',
                    human_picture: '',
                    register:'',
                },
                rules: {
                    human_email: [
                        { required: true, message: '请输入邮箱地址', trigger: 'blur' },
                        { type: 'email', message: '请输入正确的邮箱地址', trigger: ['blur', 'change'] }
                    ],
                    file: [
                        { required: true, message: '请选择图片', trigger: 'change' }
                    ],
                    vaul: [
                        { required: true, message: '请选择职位', trigger: 'change' }
                    ],
                    engage_type: [
                        { required: true, message: '请选择招聘类型', trigger: 'change' }
                    ],
                    human_name: [
                        { required: true, message: '请填写姓名', trigger: 'blur' },
                        {
                            validator: function (rule, value, callback) {
                                if (/^[\u4e00-\u9fa5]+$/.test(value) == false) {
                                    callback(new Error("请输入中文"));
                                } else {
                                    //校验通过
                                    callback();
                                }
                            },
                            trigger: "blur"
                        }
                    ],
                    deadline: [
                        { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
                    ],
                    human_telephone: [
                        { required: true, message: '请填写电话号码', trigger: 'blur' },
                        { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
                        {
                            pattern: /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/,
                            message: '请输入正确的手机号码'
                        }
                    ], 
                    human_address: [
                        { required: true, message: '请选择住址', trigger: 'change' }
                    ],
                    human_birthplace: [
                        { required: true, message: '请选择出生地', trigger: 'change' }
                    ],
                    human_nationality: [
                        { required: true, message: '请选择国籍', trigger: 'change' }
                    ],
                    human_race: [
                        { required: true, message: '请选择民族', trigger: 'change' }
                    ],
                    human_religion: [
                        { required: true, message: '请选择宗教信仰', trigger: 'change' }
                    ],
                    human_party: [
                        { required: true, message: '请选择政治面貌', trigger: 'change' }
                    ],
                    human_idcard: [
                        { required: true, message: '请填写身份证号码', trigger: 'blur' }
                    ],
                    human_college: [
                        { required: true, message: '请填选择毕业学校', trigger: 'change' }
                    ],
                    human_educated_degree: [
                        { required: true, message: '请选择学历', trigger: 'change' }
                    ],
                    human_educated_years: [
                        { required: true, message: '请选择教育年限', trigger: 'change' }
                    ],
                    human_educated_major: [
                        { required: true, message: '请选择学历专业', trigger: 'change' }
                    ],
                    demand_salary_standard: [
                        { required: true, message: '薪酬不能为空' },
                        { type: 'number', message: '薪酬必须为数字值' }
                    ],
                    register: [
                        { required: true, message: '请选择登记人', trigger: 'change' }
                    ],
                }
            },
            methods: {
                //按身份证计算出生日期,年龄,性别
                getName(idCard) {
                    let sex = null;
                    let birth = null;
                    let myDate = new Date();
                    let month = myDate.getMonth() + 1;
                    let day = myDate.getDate();
                    let age = 0;
                    age = myDate.getFullYear() - idCard.substring(6, 10) - 1;
                    if (parseInt(idCard.substring(10, 12)) >= month && parseInt(idCard.substring(12, 14)) <= day)
                    {
                        age = age+1;
                    } 
                        sex = idCard.substring(16, 17);
                        birth = idCard.substring(6, 10) + "-" + idCard.substring(10, 12) + "-" + idCard.substring(12, 14);
                    this.form.human_birthday = birth;
                    this.form.human_age = age;
                    if (sex % 2 === 0)
                        sex = '女';  // 性别代码 1代表男，0代表女，暂时不涉及其他类型性别
                    else
                        sex = '男';
                    this.form.human_sex = sex;
                },
                //图片删除事件
                handleRemove(file, fileList) {
                    console.log(file, fileList);
                },
                //图片改变事件
                handleAvatarChangeIcon(file, fileList) {
                    if (file.name.lastIndexOf('.jpg') == -1) {
                        this.$message.error('上传头像图片只能是 JPG 格式!');
                        this.fileList = [];
                    } else {
                        this.form.file = file;
                    }
                },
                eas() {
                    location.href = "/engage_major_releaseTh/engage_major_releaseTh/";
                },
                submitForm(formName) {
                    //表单验证
                    this.$refs[formName].validate((valid) => {
                        if (valid) {
                                this.$confirm('此操作将保存简历信息, 是否保存?', '提示', {
                                    confirmButtonText: '确定',
                                    cancelButtonText: '取消',
                                    type: 'warning'
                                }).then(() => {
                                    this.insert();
                                }).catch(() => {
                                    this.$message({
                                        type: 'info',
                                        message: '已取消保存'
                                    });
                                });
                        } else {
                            this.$message({
                                type: 'error',
                                message: '请填写完整信息!'
                            });
                            return false;
                        }
                    });
                },
                //简历添加
                insert() {
                    let dataPar = this.form;
                    let fdParams = new FormData();
                    fdParams.append('file', dataPar.file.raw);
                    axios.post("/WenJian/WSC",//请求后端的url
                        fdParams,
                        {
                            headers: { 'Content-Type': 'multipart/form-data' },//定义内容格式,很重要
                            timeout: 20000,
                        }
                    )
                        .then(res => {
                            axios.get('/engage_resume/Insert', {
                                params: {
                                    human_major_kind_id: this.form.human_major_kind_id,
                                    human_major_id: this.form.human_major_id,
                                    human_major_kind_name: this.form.human_major_kind_name,
                                    human_major_name: this.form.human_major_name,
                                    engage_type: this.form.engage_type,
                                    human_name: this.form.human_name,
                                    human_sex: this.form.human_sex,
                                    human_picture: res.data.toString(),
                                    human_email: this.form.human_email,
                                    human_telephone: this.form.human_telephone,
                                    human_homephone: this.form.human_homephone,
                                    human_mobilephone: this.form.human_mobilephone,
                                    human_address: this.form.human_address,
                                    human_postcode: this.form.human_postcode,
                                    human_nationality: this.form.human_nationality,
                                    human_birthplace: this.form.human_birthplace,
                                    human_birthday: this.form.human_birthday,
                                    human_race: this.form.human_race,
                                    human_party: this.form.human_party,
                                    human_idcard: this.form.human_idcard,
                                    human_age: this.form.human_age,
                                    human_college: this.form.human_college,
                                    human_educated_degree: this.form.human_educated_degree,
                                    human_educated_years: this.form.human_educated_years,
                                    human_educated_major: this.form.human_educated_major,
                                    demand_salary_standard: this.form.demand_salary_standard,
                                    human_specility: this.form.human_specility,
                                    human_hobby: this.form.human_hobby,
                                    regist_time: this.form.regist_time,
                                    human_history_records: this.form.human_history_records,
                                    remark: this.form.remark,
                                    human_religion: this.form.human_religion,
                                    register: this.form.register,
                                    interview_status: 0
                                }
                            })
                                .then(res => {
                                    console.info(res);
                                    if (res.data == 1) {
                                        this.$message({
                                            type: 'success',
                                            message: '保存成功!'
                                        });
                                        this.resetForm();
                                    }
                                    this.fill();
                                })
                                .catch(err => {
                                    console.info(err);
                                })
                        })
                        .catch(error => {
                            console.info(error);
                        });

                },
                //表单清空和图片清空
                resetForm() {
                    this.$refs['form'].resetFields();
                    this.fileList = [];
                },
                fill() {
                    //用户查询
                    axios.get('/users/que', {
                    })
                        .then(res => {
                            console.info(res);
                            this.listm = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //职位申请到简历登记的回显
                    if (@ViewBag.mre_id>0) {
                    axios.get('/engage_resume/Cx/'+@ViewBag.mre_id)
                          .then(res => {
                                  this.form.engage_type = res.data.engage_type
                                  var ruest = [];
                                  ruest.push(res.data.major_kind_id);
                                  ruest.push(res.data.major_id);
                                  this.form.vaul = ruest;
                                  this.form.human_major_kind_id = res.data.major_kind_id;
                                  this.form.human_major_id = res.data.major_id;
                                  this.form.human_major_kind_name = res.data.major_kind_name;
                                  this.form.human_major_name = res.data.major_name;
                                  this.bol = true;
                                  this.divzx2 = "display: inherit;"
                        })
                        .catch(err => {
                            console.info(err);
                        })
                    }
                    //职位查询
                    axios.get('/engage_major_release/Dgto', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                      //国籍查询
                    axios.get('/engage_resume/Gj', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list1 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //民族查询
                    axios.get('/engage_resume/Mz', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list2 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //宗教信仰
                    axios.get('/engage_resume/Zjxy', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list3 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //政治面貌
                    axios.get('/engage_resume/Zzmm', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list4 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //教育年限
                    axios.get('/engage_resume/Jynx', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list5 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //学历
                    axios.get('/engage_resume/Xl', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list6 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //专业
                    axios.get('/engage_resume/Zy', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list7 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //特长
                    axios.get('/engage_resume/Tc', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list8 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                    //爱好
                    axios.get('/engage_resume/Ah', {
                    })
                        .then(res => {
                            console.info(res);
                            this.list9 = res.data;
                        })
                        .catch(err => {
                            console.info(err);
                        });
                },
                adminSelect1(value, thsAreaCode) {
                    //获取组件名为cascaderAddr1的选中节点的labe,pathlabes获取labe数组
                    var thsAreaCode = this.$refs.cascaderAddr1.getCheckedNodes()[0].pathLabels;
                    var forminsert = value;
                    this.form.human_major_kind_id = forminsert[0];
                    this.form.human_major_id = forminsert[1];
                    this.form.human_major_kind_name = thsAreaCode[0];
                    this.form.human_major_name = thsAreaCode[1];
                },
                get() {
                    //当前时间
                    this.form.regist_time = new Date();
                },
            },
            mounted() {
                setInterval(this.get, 1000);
            },
             //可操作vue的数据和方法,但不能对dom进行操作
            created: function () {
                this.fill();
            }
        });
    </script>
    <style>
        .hide .el-upload--picture-card {
            display: none;
        }
        .kbl {
            width: 148px;
            height: 148px;
            overflow: hidden;
            float: right;
        }
        ._klpo {
            float: right;
        }
        .el-card__body {
            padding: 6px;
        }
    </style>
</body>
</html>
